/**
 * 
 */
package com.ztesoft.web.taskgenerator.service;

import java.util.List;
import java.util.Map;

import com.ztesoft.core.common.Page;
import com.ztesoft.framework.exception.BaseAppException;
import com.ztesoft.web.baseconfig.db.po.DmPlanPO;
import com.ztesoft.web.taskgenerator.db.arg.DmTaskArg;
import com.ztesoft.web.taskgenerator.db.po.DmTaskPO;

/**
 * <Description> <br>
 * 
 * @author codeCreater<br>
 * @version 1.0<br>
 * @taskId <br>
 * @CreateDate 2014年11月11日 <br>
 * @since V1.0<br>
 * @see com.ztesoft.web.taskgenerator.service <br>
 */

public interface IDmTaskService {

	DmTaskPO selectByPrimaryKey(Integer key) throws BaseAppException;

	List<DmTaskPO> selectByArg(DmTaskPO record) throws BaseAppException;

	Page<DmTaskPO> selectByArgAndPage(DmTaskPO record, Page<DmTaskPO> resultPage) throws BaseAppException;

	int add(DmTaskPO record) throws BaseAppException;

	int update(DmTaskPO record) throws BaseAppException;
	DmPlanPO changeTime(Integer dmPlanId) throws BaseAppException;
	/**
	 * 除非有“待执行且已处理了部分数据”或执行中或失败的任务，否则计划是可以进行修改的
	 * 
	 * @param dmPlanId
	 * @return success：true 可以修改 false：不能修改 info：相关提示信息
	 * @throws BaseAppException
	 */
	Map<String,Object> hasRunningTask(Integer dmPlanId) throws BaseAppException;

	int delete(DmTaskPO record) throws BaseAppException;

	/**
	 * 使用DM_PLAN_ID、GROUP_NBR查询DM_TASK，查看是否有记录
	 * 
	 * @param dmPlanId
	 * @param groupNbr
	 * @return
	 * @throws BaseAppException
	 */
	int countByArg(Integer dmPlanId, Integer groupNbr) throws BaseAppException;

	List<DmTaskPO> selectByDmTaskInfo(Integer dmPlanId, Integer groupNbr) throws BaseAppException;

	List<DmTaskPO> selectByTaskInfoNotState(Integer dmPlanId, Integer groupNbr) throws BaseAppException;

	int addBatch(List<DmTaskPO> dtLst) throws BaseAppException;

	/**
	 * 查询待生成子任务的任务列表
	 * 
	 * @param where
	 *            needSubTask = "T" and state in("00A", "00C")
	 * @return List<DmTaskPO>
	 * @throws BaseAppException
	 */
	List<DmTaskPO> selectByNeedSubtask() throws BaseAppException;

	/**
	 * 批量新增子任务
	 * 
	 * @param dtLst
	 * @return
	 * @throws BaseAppException
	 */
	int addSubBatch(List<DmTaskPO> dtLst) throws BaseAppException;

	int selectCountByArg(DmTaskArg arg) throws BaseAppException;

	int addCreateHandTask(Integer dmTaskIds) throws BaseAppException;

}
